package com.goldenautumn.prefabricate.activity.home

import android.content.Context
import android.view.ViewGroup
import android.widget.LinearLayout
import com.blankj.utilcode.util.SizeUtils
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.DataBindingHolder
import com.goldenautumn.prefabricate.R
import com.goldenautumn.prefabricate.business.entity.GoodsInfoVO
import com.goldenautumn.prefabricate.databinding.ItemHomeGoodsBinding
import com.goldenautumn.prefabricate.utils.loadImgUrl

class HomeGoodsAdapter  : BaseQuickAdapter<GoodsInfoVO, DataBindingHolder<ItemHomeGoodsBinding>>() {

    override fun onBindViewHolder(holder: DataBindingHolder<ItemHomeGoodsBinding>, position: Int, item: GoodsInfoVO?) {
        if(item == null) return
        var mBinding  = holder.binding

        mBinding.cover.loadImgUrl(item.goods_image)
        mBinding.title.text = "${item.goods_name}"
        mBinding.price.text = (String.format(context.getString(R.string.currency), "${item?.first_money}"))
    }

    override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): DataBindingHolder<ItemHomeGoodsBinding> {
        return DataBindingHolder(R.layout.item_home_goods,parent)
    }

}